package org.shop.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.shop.entity.Product;
import org.shop.service.Impl.ProductServiceImpl;
import org.shop.service.ProductService;
import org.shop.vo.PageVo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @author ZJL
 * @date 2024-12-11
 */
@WebServlet("/list_all.do")
public class ListAllProductServlet extends BaseController {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");

        //实例化 service
        ProductService productService = new ProductServiceImpl();
        //调用 service 对象的方法
        List<Product> list = productService.getProductAll();
        print(resp,success(list,list.size()));
    }
}
